package ${packageController};

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tdcy.framework.BaseController;
import com.tdcy.framework.util.JsonUtils;
import com.tdcy.framework.util.RequestUtils;
import com.tdcy.framework.util.WebUtils;
import ${packageDAO}.I${tableJavaClassName}DAO;
import ${packageEO}.${tableJavaClassName}EO;
import ${packageBean}.${tableJavaClassName}QueryCondition;
import com.tdcy.framework.bean.PageInfo;
import ${packageService}.I${tableJavaClassName}Svc;
/**
* @Description ${tableComments}Controller
*/
@Controller
@RequestMapping(value = "/${tableFirstName}")
public class ${tableJavaClassName}Controller extends BaseController {
	@Resource
	I${tableJavaClassName}Svc ${tableName}Svc;
	
	@Resource
	I${tableJavaClassName}DAO ${tableName}DAO;
	
	@ResponseBody
	@RequestMapping(value = "/getAll${tableJavaClassName}", method =RequestMethod.POST)
	public Object getall${tableJavaClassName}() throws IOException {
		List<${tableJavaClassName}EO> eolist = ${tableName}Svc.getAll${tableJavaClassName}();
		return WebUtils.createJSONSuccess("数据加载成功", eolist);
	}
	
	@ResponseBody
	@RequestMapping(value = "/get${tableJavaClassName}Page", method =RequestMethod.POST)
	public Object getpage${tableJavaClassName}(${tableJavaClassName}QueryCondition qc) throws IOException {
		PageInfo<${tableJavaClassName}EO> page = ${tableName}DAO.getPage${tableJavaClassName}(qc);
		return WebUtils.createJSONSuccess("数据加载成功", page);
	}
	
	@ResponseBody
	@RequestMapping(value = "/get${tableJavaClassName}List", method =RequestMethod.POST)
	public Object getlist${tableJavaClassName}(${tableJavaClassName}QueryCondition qc) throws IOException {
		List<${tableJavaClassName}EO> eolist = ${tableName}DAO.getList${tableJavaClassName}(qc);
		return WebUtils.createJSONSuccess("数据加载成功", eolist);
	}
	

	@ResponseBody
	@RequestMapping(value = "/add${tableJavaClassName}", method =RequestMethod.POST)
	public Object add${tableJavaClassName}(${tableJavaClassName}EO ${tableName}) throws IOException {
		${tableJavaClassName}EO eo = ${tableName}Svc.add${tableJavaClassName}(${tableName});
		return WebUtils.createJSONSuccess("添加成功", eo);
	}

	@ResponseBody
	@RequestMapping(value = "/update${tableJavaClassName}", method =RequestMethod.POST)
	public Object update${tableJavaClassName}(${tableJavaClassName}EO ${tableName}) throws IOException {
		${tableJavaClassName}EO eo = ${tableName}Svc.update${tableJavaClassName}(${tableName});
		return WebUtils.createJSONSuccess("更新成功", eo);
	}

	@ResponseBody
	@RequestMapping(value = "/del${tableJavaClassName}", method =RequestMethod.POST)
	public Object del${tableJavaClassName}(@RequestParam("${pkFieldId}") Integer ${pkFieldId}) throws IOException {
		boolean flag = ${tableName}Svc.del${tableJavaClassName}(${pkFieldId});
		return WebUtils.createJSONSuccess("删除成功", flag);
	}

	@ResponseBody
	@RequestMapping(value = "/get${tableJavaClassName}Info", method =RequestMethod.POST)
	public Object get${tableName}info(@RequestParam("${pkFieldId}")Integer ${pkFieldId}) throws IOException {
		${tableJavaClassName}EO eo = ${tableName}Svc.get${tableJavaClassName}Info(${pkFieldId});
		return WebUtils.createJSONSuccess("获取成功", eo);
	}

}
